package kr.hkit.powerjava.chapter24.work3;

import java.io.Serializable;

import kr.hkit.powerjava.chapter24.work3.Student;

public class Student  implements Serializable , Comparable<Student> {
	private int Num;
	private String Name;
	private int kog;
	private int eng;
	private int math;
	
	public int getNum() {
		return Num;
	}
	public void setNum(int num) {
		Num = num;
	}
	public String getName() {
		return Name;
	}
	public void setName(String name) {
		Name = name;
	}
	public int getKog() {
		return kog;
	}
	public void setKog(int kog) {
		this.kog = kog;
	}
	public int getEng() {
		return eng;
	}
	public void setEng(int eng) {
		this.eng = eng;
	}
	public int getMath() {
		return math;
	}
	public void setMath(int math) {
		this.math = math;
	}
	public Student(int num, String name) {
		Num = num;
		Name = name;
	}
	public Student(int num, String name, int kog, int eng, int math) {
		Num = num;
		Name = name;
		this.kog = kog;
		this.eng = eng;
		this.math = math;
	}
	
	public int total(){
		return kog+eng+math;
	}
	public double avg(){
		return total()/3.0;
	}
	
	
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Student ){
			Student temp= (Student)obj;
		return Num == temp.Num && Name.equals(temp.Name);
		}else {
			return false;
		}
		
	}
	@Override
	public String toString() {
		return String
				.format("%3s\t %5s\t %3s\t %3s\t %3s\t %3s\t %6.3f]",
						Num, Name, kog, eng, math, total(), avg());
	}
	@Override
	public int compareTo(Student o) {
		return Num - o.Num;
	}
	
}
